package cn.ac.cintcm.synonymous;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class ErrorData {
    static File outputFile;
    static BufferedWriter writer;
    private static String metaData;
    static {
    }
    public static void write(String field, String data) {
        try {
            writer.write(metaData + ":" + field + ":" + data);
            writer.write(System.getProperty("line.separator"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    
    public static void close() {
        try {
            writer.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void open() {
        try {
            outputFile = new File(System.getProperty("user.dir"), "error.txt");
            writer = new BufferedWriter(new FileWriter(outputFile));
        } catch (IOException e) {
            e.printStackTrace();
        }        
    }

    public static void setMetaData(String filename) {
        metaData = filename;
        
    }
}
